import axios from 'axios'


// const service = axios.create({
//   baseURL: process.env.IP_URL,
//   timeout: 5000
// })


service.interceptors.request.use(
  config => {
    // if (store.getters.token) {
    //   config.headers['X-Token'] = getToken()
    // }
    return config
  },
  error => {
    return Promise.reject(error)
  }
)


service.interceptors.response.use(
  response => {

    console.log(response)

    // const res = response.data

    // if (res.code !== 0) {
    //   return Promise.reject(new Error(res.message || 'Error'))
    // } else {
    //   return res
    // }

  },
  error => {
    const res = error.response.data
    Message({
      message: res.message || 'Error',
      type: 'error',
      duration: 5 * 1000
    })
    return Promise.reject(error)
  }

)

export default service
